home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: compilers
- Date: Fri, 22 Mar 96 20:45:27 GMT
- Organization: none
- Message-ID: <827527527snz@genesis.demon.co.uk>
- References: <4iburm$aps@airdmhor.gen.nz> <DoBvF6.GG5@iquest.net> <4ihcld$iln@airdmhor.gen.nz>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4ihcld$iln@airdmhor.gen.nz>
- gumboot@airdmhor.gen.nz "Simon Hosie" writes:
-
- >gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
- >> Does anyone know of a compiler that can take
- >>
- >> for (;;)
- >> {
- >> Stuff(1);
- >> if (Cond)
- >> break;
- >> Stuff(2);
- >> }
- >>
- >> and make
- >>
- >> goto EntryPoint;
- >> do
- >> {
- >> Stuff(2);
- >> EntryPoint:
- >> Stuff(1);
- >> } while (Cond);
- >
- >Doug Miller:
- >> A possibly more important question is why you would want it to, since the
- > first form is vastly
- >> more comprehensible.
- >
- > Well, it would compile it, so you'd never get to see the difference, but
- >the latter has only 1 conditional jump and no 'definite'jumps in the inner
- >loop whereas the former has 1 conditial jump (not usually taken) and a
- >'definite' jump.
-
- And it is one of the more trivial optimisations for a compiler to rearrange
- loops for efficiency. Concern yourself with clarity in the source code - let
- the compiler deal with generating efficient object code. It may even find
- a better way than generating code equivalent to the 2nd form so it is
- unwise to 2nd guess it.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-